﻿using System;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Volo.Abp;
using Volo.Abp.Application.Dtos;
using Volo.Abp.Identity;

namespace Acme.BookStore2.Controllers
{
    [RemoteService(Name = "Default")]
    [Area("bookstore2")]
    [ControllerName("Vehicle")]
    [Route("api/bookstore2/vehicles")]
    public class VehicleController : BookStore2Controller, IVehicleAppService
    {
        private readonly IVehicleAppService _vehicleAppService;

        public VehicleController(IVehicleAppService vehicleAppService)
        {
            _vehicleAppService = vehicleAppService;
        }
        
        [HttpGet]
        [Route("{id}")]
        public Task<VehicleDto> GetAsync(Guid id)
        {
            return _vehicleAppService.GetAsync(id);
        }
        
        [HttpGet]
        public Task<PagedResultDto<VehicleDto>> GetPagedListAsync(GetVehiclesInput input)
        {
            return _vehicleAppService.GetPagedListAsync(input);
        }
        
        [HttpPost]
        public Task<VehicleDto> CreateAsync(VehicleCreateDto input)
        {
            return _vehicleAppService.CreateAsync(input);
        }

        [HttpPut]
        [Route("{id}")]
        public Task<VehicleDto> UpdateAsync(Guid id, VehicleUpdateDto input)
        {
            return _vehicleAppService.UpdateAsync(id, input);
        }

        [HttpDelete]
        [Route("{id}")]
        public Task DeleteAsync(Guid id)
        {
            return _vehicleAppService.DeleteAsync(id);
        }

        [HttpGet]
        [Route("export")]
        public Task ExportAsync(GetVehiclesInput input)
        {
            return _vehicleAppService.ExportAsync(input);
        }

        [HttpPut]
        [Route("{id}/SetMaintenance")]
        public Task<VehicleDto> SetMaintenanceAsync(Guid id, SetMaintenanceInput input)
        {
            return _vehicleAppService.SetMaintenanceAsync(id, input);
        }
    }
}